home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / soul.cc < prev    next >
C/C++ Source or Header  |  1995-02-22  |  629b  |  55 lines

  1. /*    Copyright Alex Hornby 1994/1995. All rights reserved.
  2.      See file README for details
  3. */
  4.  
  5. #include "soul.h"
  6.  
  7. Soul :: Soul(int l, int e, int v) 
  8. {
  9.     score=0;
  10.     lives=l;
  11.     maxenergy=energy=e;
  12.     value=v;
  13. }
  14.  
  15. Soul :: Soul( const Soul& s) 
  16. {
  17.     copy(s);
  18. }
  19.  
  20. void
  21. Soul :: copy(const Soul &s)
  22. {
  23.     lives=s.lives;
  24.     energy=s.energy;
  25.     maxenergy=s.energy;
  26.     score=s.score;
  27.     value=s.value;
  28. }
  29.  
  30. Soul& 
  31. Soul :: operator=(const Soul& s)
  32. {
  33.     copy(s);
  34.     return *this;
  35. }
  36.  
  37. void
  38. Soul :: subEnergy(int e)
  39. {
  40.     energy-=e;
  41.     if(energy<=0)
  42.     {
  43.         energy=maxenergy;    
  44.         lives--;
  45.     }
  46. }
  47.  
  48. void
  49. Soul :: addEnergy(int e)
  50. {
  51.     energy+=e;
  52.     if(energy>maxenergy)
  53.         energy=maxenergy;
  54. }
  55.